/**
 * 
 */
package com.demo2do.boyle.common.entity.aduser.refund;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.demo2do.boyle.common.entity.aduser.Aduser;
import com.demo2do.boyle.common.entity.advertisement.Advertisement;

/**
 * @author Leo
 *
 */
@Entity
@Table( name = "aduser_refund")
public class AduserRefund {

	@Id
	@GeneratedValue
	private Integer id;
	
	@ManyToOne(optional = false, fetch = FetchType.LAZY)
	private Aduser aduser;
	
	@ManyToOne(optional = false, fetch = FetchType.LAZY)
	private Advertisement advertisement;
	
	private int balance;
	
	@Enumerated(EnumType.ORDINAL)
	@Column(name = "status")
	private RefundStatus refundStatus;
	
	private Date createTime;
	
	/** 退款时间 */
	private Date completeTime;
	
	private String auditor;

	/**
	 * The default constructor
	 */
	public AduserRefund() {
		
	}
	
	/**
	 * audit refund and set status
	 * 
	 * @return
	 */
	public AduserRefund audit() {
		this.refundStatus = RefundStatus.PAID;
		this.completeTime = new Date();
		return this;
	}
	
	/**
	 * 
	 * @param auditor
	 * @return
	 */
	public AduserRefund operator(String auditor) {
		this.auditor = auditor;
		return this;
	}

	/**
	 * @return the id
	 */
	public Integer getId() {
		return id;
	}

	/**
	 * @return the aduser
	 */
	public Aduser getAduser() {
		return aduser;
	}

	/**
	 * @return the advertisement
	 */
	public Advertisement getAdvertisement() {
		return advertisement;
	}

	/**
	 * @return the balance
	 */
	public int getBalance() {
		return balance;
	}

	/**
	 * @return the refundStatus
	 */
	public RefundStatus getRefundStatus() {
		return refundStatus;
	}

	/**
	 * @return the createTime
	 */
	public Date getCreateTime() {
		return createTime;
	}

	/**
	 * @return the auditor
	 */
	public String getAuditor() {
		return auditor;
	}

	/**
	 * @return the completeTime
	 */
	public Date getCompleteTime() {
		return completeTime;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * @param aduser the aduser to set
	 */
	public void setAduser(Aduser aduser) {
		this.aduser = aduser;
	}

	/**
	 * @param advertisement the advertisement to set
	 */
	public void setAdvertisement(Advertisement advertisement) {
		this.advertisement = advertisement;
	}

	/**
	 * @param balance the balance to set
	 */
	public void setBalance(int balance) {
		this.balance = balance;
	}

	/**
	 * @param refundStatus the refundStatus to set
	 */
	public void setRefundStatus(RefundStatus refundStatus) {
		this.refundStatus = refundStatus;
	}

	/**
	 * @param createTime the createTime to set
	 */
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	/**
	 * @param auditor the auditor to set
	 */
	public void setAuditor(String auditor) {
		this.auditor = auditor;
	}

	/**
	 * @param completeTime the completeTime to set
	 */
	public void setCompleteTime(Date completeTime) {
		this.completeTime = completeTime;
	}
	
}
